<template>
  <base-breadcrumb>
    <!-- 搜索 -->
    <searchData :searchData="searchArr" @search2="search"></searchData>
    <!-- 表格 -->
    <a-card :bordered="false">
      <!-- <title-name title="分包商月度评价表" /> -->
      <list-table
        ref="table"
        :columns="columns"
        :request="loadData"
      >
        <template slot="prefix" slot-scope="text, record" v-if="hideBuquBtn()">
          <a-button type="primary" icon="plus" @click="option({},'add')" v-btnPermission="'hse_042_add_01'" >
            新增
          </a-button>
        </template>
        <template slot="action" slot-scope="text, record">
          <MoreButton>
            <a v-btn-permission="'hse_042_loo_04'" @click="option(record, 'look')">查看</a>
<!--            <template v-if="record.auditStatus !== 'SUBMITTED'">-->
              <a v-btn-permission="'hse_042_edi_02'" @click="option(record, 'edit')" v-if="hideBuquBtn()">编辑</a>
              <a v-btn-permission="'hse_042_del_03'" @click="handleDelete(record)" v-if="hideBuquBtn()">删除</a>
<!--            </template>-->
          </MoreButton>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目名称
import rectifyNoticeApi from '@/api/safetySupervision/checkAndRectify/rectifyNotice'
import { saveAs } from 'file-saver'
import BSelect from '@/components/BComponents/BSelect'
import api from '@/api/safetySupervision/subcontractorComment'
import SelectCompanyAndSubCompany from '@/components/Select/SelectCompanyAndSubCompany'
import subcontractorLevelApi from '@/api/safetySupervision/base/constructionStage.js'
import { getSubcontractor } from '@/api/businessAffairs/sml'
import SelectSubcontractor from '@/components/Select/SelectSubcontractor'

export default {
  name: 'a' + Date.now(),
  components: {},
  data() {
    return {
      searchArr: [
        { name: '考核单位', type: SelectSubCompany, valueKey: 'orgId', getAll: true, showSearch: true },
        {
          type: BSelect,
          valueKey: 'subId',
          keyValue: 'orgId',
          init: false,
          isSearch: true,
          name: '被考核单位',
          keys:['subContractorId','name'],
          request: e => {
            return api.subContractorList({ id: e })
          }
        },
        {
          name: '分包单位引进级别', type: BSelect, valueKey: 'cataId', request: () => {
            return subcontractorLevelApi.list({}, { type: 2, 'haveTree': false })
          }
        },
        {
          name: '分包单位类型', type: BSelect, valueKey: 'cataDetailsId',
          init: false,
          isSearch: true,
          keyValue: 'cataId',
          request: k => {
            return subcontractorLevelApi.findListByDetails({}, { type: 2, cataId: k })
          }
        },
        {
          name: '考核得分', type: 'select', value: 'scoreType',
          data: [
            { value: 1, label: '85分以上' },
            { value: 2, label: '75~85分(不含)' },
            { value: 3, label: '65~75分(不含)' },
            { value: 4, label: '65分(不含)以下的' }
          ]
        },
        {
          name: '一票否决项', type: 'select', value: 'veto',
          data: [
            { value: true, label: '是' },
            { value: false, label: '否' }
          ]
        },
        {
          name: '月份', type: 'month', value: 'yearMon'
        },
        {
          name: '填报人', type: 'input', value: 'creatorName'
        }
      ],
      columns: [
        { title: '年份', dataIndex: 'yearMon',width: 100},
        { title: '考核单位', dataIndex: 'orgName',width: 150},
        { title: '被考核单位', dataIndex: 'name',width: 250,},
        { title: '分包单位引进级别', dataIndex: 'cataName',width: 150},
        { title: '分包单位类型', dataIndex: 'cataDetailsName',width: 200},
        { title: '考核得分', dataIndex: 'score',width: 100},
        { title: '一票否决项', dataIndex: 'vetoStr',width: 120},
        { title: '考核日期', dataIndex: 'createTime',width: 120},
        { title: '填报人', dataIndex: 'creatorName',width: 100},
        { title: '状态', dataIndex: 'auditStatusStr',width: 100},
        {
          title: '操作',
          dataIndex: 'action',
          width: 200,
          fixed: 'right',
          scopedSlots: { customRender: 'action' }
        }
      ],
      queryParam: {},
      loadData: (parameter) => {
        const q = Object.assign({}, parameter, { query: { ...this.queryParam, type: 2 } })
        return api.findListByMain({}, q)
      }
    }
  },
  methods: {
    search(value) {
      value && (this.queryParam = value)
      this.$refs.table.refresh()
    },
    option(row, pageType) {
      this.$router.push({
        path: '/safetySupervision/subcontractorComment/monthSubCompanyAdd',
        query: {
          id: row.id,
          pageType
        }
      })
    },
    handleDelete(e) {
      this.$delList2(api.deleteByMain, () => {
        this.search()
      }, { ids: [e.id] })
    }
  }
}
</script>


